package com.asb.utils;

import java.time.LocalTime;
import java.util.Map;

import org.apache.log4j.Logger;

import com.alibaba.fastjson.JSON;
import com.taobao.api.ApiException;

public class JsonUtil {
	
	public static Logger log = Logger.getLogger(JsonUtil.class);
	
	public static Map<String, Object> toRes(String jsonString) throws ApiException {
		
		Map<String, Object> jsonObj = JSON.parseObject(jsonString);
		
		return (Map<String, Object>) jsonObj.get("result");
	}
	
	public static Map<String, Object> toTask(String jsonString) throws ApiException {
		
		return JSON.parseObject(jsonString);
	}
	
	public static Map<String, Object> toBody(String jsonString) throws ApiException {
		
		Map<String, Object> jsonObj = JSON.parseObject(jsonString);
		
		return (Map<String, Object>) jsonObj.get("body");
	}
	
	public static Map<String, Object> toProcess(String jsonString) throws ApiException {
		
		Map<String, Object> jsonObj = JSON.parseObject(jsonString);
		
		return (Map<String, Object>) jsonObj.get("process_instance");
	}
	
public static Integer toErrorCode(String jsonString) throws ApiException {
		
		Map<String, Object> jsonObj = JSON.parseObject(jsonString);
		
		return Integer.parseInt(String.valueOf(jsonObj.get("errcode"))) ;
	}
}
